<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="integralLog-form">
					<div class="select-list">
						<ul>
							<li>
								<label>员工姓名： </label><input type="text" name="userName"/>
							</li>
							<li>
								<label>部门名称： </label><select name="userDeptId" th:with="dept=${@dept.getDept()}" class="form-control m-b-none">
								<option value="">所有</option>
								<option th:each="dept : ${dept}" th:text="${dept.deptName}" th:value="${dept.deptId}"></option>
							</select>
							</li>
							<li>
								<label>职位名称： </label><select name="userPostId" th:with="post=${@post.getPost()}" class="form-control m-b-none">
								<option value="">所有</option>
								<option th:each="post : ${post}" th:text="${post.postName}" th:value="${post.postId}"></option>
							</select>
							</li>
							<li>
								<label>撤销状态： </label><select name="status" class="form-control m-b-none">
								<option value="">所有</option>
								<option value="0">未撤销</option>
								<option value="1">已撤销</option>
								<option value="2">不能撤销</option>
							</select>
							</li>
							<li>
								<label>积分类型： </label><select name="typeId" class="form-control m-b-none">
								<option value="">所有</option>
								<option value="">品德A分</option>
								<option value="">业绩B分</option>
								<option value="">行为C分</option>
							</select>
							</li>
							<li class="select-time">
								<label>获取积分时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
			</div>

			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
		<!--<div class="btn-group-sm hidden-xs" id="toolbar" role="group">-->
			<!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="integral:integralLog:add">-->
				<!--<i class="fa fa-plus"></i> 添加-->
			<!--</a>-->
			<!--<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="integral:integralLog:edit">-->
	            <!--<i class="fa fa-edit"></i> 修改-->
	        <!--</a>-->
			<!--<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="integral:integralLog:remove">-->
				<!--<i class="fa fa-remove"></i> 删除-->
			<!--</a>-->
		<!--</div>-->
			<!---->
		<!--<div class="col-sm-12 select-table table-striped">-->
			<!--<table id="bootstrap-table" data-mobile-responsive="true"></table>-->
		<!--</div>-->
    </div>
    <div th:include="include :: footer"></div>
	<script th:src="@{/ajax/libs/select/select2.js}"></script>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('integral:integralLog:edit')}]];
        var removeFlag = [[${@permission.hasPermi('integral:integralLog:remove')}]];
        var undoFlag = [[${@permission.hasPermi('integral:integralLog:undo')}]];

        var prefix = ctx + "integral/integralLog";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "积分日志",
                columns: [{
		            checkbox: true
		        },
                {
                    formatter: function (value, row, index) {
                        return index+ 1;
                    }
                },
				// {
				// 	field : 'logId', 
				// 	title : '积分日志' 
				// },
				{
					field : 'approvalNum',
					title : '审批编号'
				},
				 {
				 	field : 'userPost',
				 	title : '员工职位'
				 },
				{
				 	field : 'userDept',
				 	title : '员工部门'
				 },
				 {
					field : 'userPhone',
					title : '员工手机号'
				 },
				{
					field : 'userName', 
					title : '员工姓名' 
				},
				{
                    field : 'userImg',
                    title : '获得积分员工头像',
                    formatter: function(value, row, index) {
                        if (value) {
                            return `<img src=${value} width="100" height="100"></img>`
                        } else {
                            return '没有上传头像'
                        }
                    }
                },
				// {
				// 	field : 'userDept', 
				// 	title : '员工部门' 
				// },
				// {
				// 	field : 'userPost', 
				// 	title : '员工职位' 
				// },
				{
					field : 'integralTitle', 
					title : '积分项目',
					width : 204
				},
				{
					field : 'integralContent', 
					title : '积分内容',
					width: 204
				},
				{
					field : 'bianIntegral', 
					title : '添加积分'
				},
                {
                    field : 'kIntegral',
                    title : '扣除积分',
                    formatter: function (value) {
                        if (value != null && value != 0) {
                            return '-' + value;
                        }
                    }
                },
                {
                    field : 'typeId',
                    title : '积分类型',
					formatter: function (value) {
						switch (value) {
							case 1: return '品德A分';
							case 2: return '业绩B分';
							case 3: return '行为C分';
                        }
                    }
                },
                    {
					field : 'getTime', 
					title : '获取积分时间' 
				},
                    {
					field : 'status',
					title : '撤销状态',
                    formatter: function (value) {
                        switch (value) {
                            case 0: return '<span class="badge badge-info">未撤销</span>';
                            case 1: return '<span class="badge badge-important">已撤销</span>';
                            case 2: return '<span class="badge badge-success">不能撤销</span>';
                        }
                    }
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];

		            	if (row.status == '0') {
	                        actions.push('<a class="btn btn-danger btn-xs ' + undoFlag + '" href="#" onclick="undo(\'' + row.logId +'|'+ row.status + '\')"><i class="fa fa-remove"></i>撤销积分</a>');
						} else if (row.status == '1') {
							actions.push('<a class="btn btn-primary btn-xs ' + undoFlag + '" href="#" onclick="undo(\'' + row.logId +'|'+ row.status + '\')"><i class="fa fa-refresh"></i>还原积分</a>');
						} else {
							actions.push('<a class="btn btn-danger btn-xs disabled ' + undoFlag + '" href="#" onclick="undo(\'' + row.logId +'|'+ row.status + '\')"><i class="fa fa-remove"></i>撤销积分</a>');
						}

						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

        /** 撤销审批 减少积分*/
        function undo(params) {
            params= params.split('|');
			var status = null;
			var approvalId = null;
			approvalId = params[0];
			status = params[1];
            var url = prefix + '/undo/' + approvalId+ '/' + status;
            // $.modal.open("审批通过",url,'300','200');
            $.operate.submit(url, "get", "json", "");
        }
    </script>
</body>
</html>